<template>
	<view>
		<image mode="widthFix" :src="src" class="bgImg"></image>
		<!-- 全部课程 -->
		<view class='courseBox'>
			<view class="courseTitle">全部课程</view>
			<view class='courseList' v-for="(course, index) in courseList" :key="index" @click="navTo(`/pages/course/course-details?id=${course.id}`)">
				<view class='leftCont'>
					<image :src='course.mainImage'></image>
				</view>
				<view class='rightCont'>
					<view>
						<view class='fs_30'>{{course.title}}</view>
						<view class='orderInfo'>{{course.studyTotal}}人学过</view>
					</view>
					<view class='justify_between'>
						<view class='price' v-if="!course.isFree">￥{{course. priceDiscount}}<text>￥{{course.priceOriginal}}</text></view>
						<view class="price" v-else>免费</view>
					</view>
				</view>
			</view>
		</view>
		<image mode="widthFix" :src="bottomImg" class="bgImg"></image>
	</view>
</template>

<script>
	import api from '../../../api/education.js'
	export default {
		data() {
			return {
				teacher:null,
				src: 'http://127.0.0.1:3001/static/education/teacher_bg.png',
				courseList: [],
				bottomImg: 'http://127.0.0.1:3001/static/education/teacher_di.png'
			}
		},
		onLoad(option) {
				// console.log("teacher",option)
				this.teacher = JSON.parse(option.teacher)
				console.log("teacher",this.teacher)
				this.getCourselist(this.teacher.id)
		},
		methods: {
			async getCourselist( teacherid ) {
				const { data } = await api.getcourseByteacherid(teacherid)
				this.courseList= data
				// console.log(this.courseList)
			}
		}
	}
</script>

<style>
	.bgImg {
		width: 100%;
		display: block;
	}

	.courseBox {
		padding: 20rpx 40rpx;
		background-color: #0D47A1;
		margin-top: -2rpx;
	}

	.courseTitle {
		color: #fff;
		position: relative;
		margin-bottom: 20rpx;
		margin-left: 30rpx;
		padding-left: 30rpx;
		font-size: 34rpx;
	}

	.courseTitle::after {
		content: "";
		position: absolute;
		top: 6rpx;
		left: 0;
		background-color: #fff;
		width: 16rpx;
		height: 32rpx;
	}

	.courseList {
		display: flex;
		background: #3D6CB4;
		padding: 20rpx;
		margin-bottom: 20rpx;
		border-radius: 10rpx;
	}

	.leftCont image {
		width: 290rpx;
		height: 160rpx;
		display: block;
	}

	.cardImg {
		width: 294rpx;
		height: 194rpx;
	}

	.rightCont {
		width: 100%;
		margin-left: 30rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		color: #fff;
	}

	.notFull {
		color: #ec691a;
	}

	.full {
		color: #aaa;
	}

	.orderInfo {
		font-size: 24rpx;
		line-height: 2;
		color: #ABBFDE;
	}

	.price {
		font-size: 34rpx;
		color: #f14927;
	}

	.price text {
		font-size: 24rpx;
		color: #ACBBDA;
		text-decoration: line-through;
	}
</style>
